package InetAdress;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;

public class outputAdress01 {
    public static void main(String[] args) throws IOException {
        //链接服务端IP，端口
        Socket socket=new Socket(InetAddress.getLocalHost(),9999);
        System.out.println(socket.getClass());
        OutputStream outputStream= socket.getOutputStream();
        outputStream.write("hello,socket".getBytes());
        socket.shutdownOutput();

        byte[] b=new byte[1024];
        int n=0;
        InputStream inputStream=socket.getInputStream();
        while ((n=inputStream.read(b))!=-1){
            System.out.println(new String(b,0,n));
        }
        //socket.shutdownInput();

        inputStream.close();
        socket.close();
        outputStream.close();
    }
}
